home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January
/
CHIP_CD_01_2007.iso
/
Hity z okladki
/
OrgPlus 6 SBE
/
ORGPL.CAB
/
indexPage.js
< prev
next >
Wrap
Text File
|
2006-09-20
|
10KB
|
410 lines
/**********************************************************
* *
* (C) Copyright 2002 - 2004, Human Concepts (tm) *
* *
***********************************************************
* File name: indexPage.js *
* Author: Andrey Ponomarev *
**********************************************************/
window.onload = doInit
window.onresize = onResize
var bCapture = false
function onResize()
{
var nWidth = document.body.clientWidth
if( typeof(PersonList) == "object" )
PersonList.style.width = nWidth + 3
if( typeof(ListResizer) == "object" )
ListResizer.style.width = nWidth
}
function doInit()
{
CreateControls()
var obj = top.hcMain
if ( typeof (obj) == "object" && typeof (obj.onNavigatePageInit) != "undefined" )
obj.onNavigatePageInit()
}
function clearPage()
{
CreateControls()
TitleText.innerText = ""
var num = PersonList.length
for (i = num; i > 0; i--)
PersonList.remove(i-1)
//PersonList.innerText = ""
PersonInfo.innerText = ""
top.hcMain.focus()
}
var idxArray = null;
var idxCount = 0;
function fillIndexArray(person)
{
idxArray[idxCount++] = person
var spanObjs = person.children.tags("span")
for(var j = 0; j < spanObjs.length; ++j)
{
fillIndexArray(spanObjs[j])
}
if(spanObjs.length == 0)
return
}
function fillPage(group)
{
clearPage()
if( typeof( group ) == "object" )
{
if(typeof( top.hcPersons ) == "object")
{
var fieldsObj = top.hcMain.getFieldsObj()
if(fieldsObj == null) return
var nID = ProcessHeaders(fieldsObj)
if (nID == -1)
return; //Error!
var id = group.id
var objPerson = top.hcMain.findPersonNode(id,null)
if(objPerson == null) return
idxArray = new Array()
idxCount = 0
fillIndexArray(objPerson)
for (j = 0; j < idxArray.length; j++)
{
AddListItem(idxArray[j], nID, j)
}
var objFirst = PersonList.options(0)
if ( objFirst != null && typeof(objFirst) == "object" )
{
objFirst.setAttribute('selected', true)
ShowInfo(0)
}
top.hcMain.focus()
return
}
}
top.hcMain.focus()
}
function ProcessHeaders(objHeaders)
{
var nID = -1
if( typeof(objHeaders) == "object" )
{
var strTitle = ""
var paramObjs = objHeaders.getElementsByTagName("param")
for (var j = 0; j < paramObjs.length; j++)
{
var obj = paramObjs(j)
if (obj.name != null)
{
if (strTitle == "")
strTitle = obj.name
if (nID == -1 && obj.id != null)
nID = obj.id
if (obj.value == "i")
{
strTitle = obj.name
if (obj.id != null)
nID = obj.id
break
}
}
} //for
TitleText.innerText = "Persons (" + strTitle + "):" //Loc
}
return nID
}
function CreateControls()
{
var topPos = 2
var elem
if ( typeof(TitleText) == 'undefined' )
{
elem = document.createElement("v:textbox")
elem.className = 1
elem.id = "TitleText"
elem.style.top = topPos
elem.style.height = nFontSize
elem.style.width = 400
document.body.appendChild(elem)
}
topPos += nFontSize + 1
var nListHeight = nFontSize * 20
if ( typeof(PersonList) == 'undefined' )
{
elem = document.createElement("select")
elem.id = 'PersonList'
elem.className = 1
elem.style.top = topPos
elem.style.height = nListHeight
elem.style.left = -2
elem.size = 2
elem.multiple = false
document.body.appendChild(elem)
}
topPos += nListHeight + 5
if ( typeof(ListResizer) == 'undefined' )
{
elem = document.createElement("hr")
elem.id = 'ListResizer'
elem.style.position = 'absolute'
elem.style.top = topPos
elem.style.height = 3
if (getIEVersion() < 6.0)
elem.style.cursor= 's-resize'
else
elem.style.cursor= 'row-resize'
elem.style.left = 0
elem.style.zIndex = 1
document.body.appendChild(elem)
}
if ( typeof(PersonInfo) == 'undefined' )
{
elem = document.createElement("p")
elem.id = 'PersonInfo'
document.body.appendChild(elem)
}
onResize()
}
function AddListItem(objPerson, nID, nValue)
{
var paramObjs = objPerson.getElementsByTagName("param")
var obj = null;
for (i = 0; i < paramObjs.length; ++i)
{
var o = paramObjs(i)
if (o.id == nID)
{
obj = o
break;
}
}
if (obj != null)
{
var str = obj.name
if (typeof(str) != "undefined" && str != "")
{
var objOption = document.createElement("option")
objOption.text = str
objOption.value = nValue
PersonList.add(objOption)
}
}
}
function ShowInfo(nPerson)
{
if ( idxArray != null && idxArray.length > nPerson)
{
PersonInfo.innerText = ""
var spanObj = idxArray[nPerson]
ShowPersonInfo(spanObj)
}
}
function ShowPersonInfo(objPerson)
{
var fieldsObj = top.hcMain.getFieldsObj()
if ( fieldsObj == null)
return //Error
var titleObjs = fieldsObj.children.tags("param")
var paramObjs = objPerson.children.tags("param")
var k = 0;
for (i = 0; i < titleObjs.length; ++i)
{
var objTitle = titleObjs(i)
for (j = 0; j < paramObjs.length; j++)
{
var obj = paramObjs(j)
if (objTitle.id == obj.id)
{
var strName = objTitle.name
if ( typeof(strName) == 'undefined' )
strName = ""
var strValue = obj.name
if ( typeof(strValue) == 'undefined' )
strValue = ""
var strImage = obj.value
if ( typeof(strImage) == 'undefined' )
strImage = ""
AddPersonInfoItem(k, strName, strValue, strImage)
++k;
break;
}
}
}
}
function isEmail(str)
{
return str.search('@') >= 0
}
var topPos = 0
function AddPersonInfoItem(i, strName, strValue, strImage)
{
var bImageFlag = strImage.length > 0
if (i == 0)
topPos = parseInt(ListResizer.style.top) + 10 //nFontSize * 24
else
topPos += nFontSize + 1
var elem = document.createElement("v:textbox");
var strText = strName + ':';
if (!bImageFlag)
strText += ' ' + strValue;
elem.style.width = strText.length * nFontSize
elem.innerText = strText
elem.className = 1
elem.style.top = topPos
elem.style.height = nFontSize
if (!bImageFlag && isEmail(strValue))
{
var anc = document.createElement("a")
anc.setAttribute("href", "mailto:" + strValue)
PersonInfo.appendChild(anc)
anc.appendChild(elem)
}
else
{
PersonInfo.appendChild(elem)
}
if (bImageFlag)
{
var nImageSize = nFontSize * 8
topPos += nFontSize + 1
var objImage = document.createElement("img")
objImage.className = 1
objImage.style.top = topPos
PersonInfo.appendChild(objImage)
objImage.style.height = nImageSize
objImage.setAttribute("src", strImage)
topPos += nImageSize - nFontSize
}
}
function OnSelected(strValue)
{
var nValue = parseInt(strValue)
ShowInfo(nValue)
}
function OnDblClicked(strValue)
{
var nPerson = parseInt(strValue)
if ( idxArray != null && idxArray.length > nPerson)
{
var spanObj = idxArray[nPerson]
var strSrc = spanObj.src
if ( typeof(strSrc) == 'string' && strSrc != "")
ShowBox(strSrc)
}
}
function ShowBox(strSrc)
{
var hcMain = top.hcMain
//if (hcMain.location != strSrc)
{
var s = strSrc.split("#")
if(s.length!=2) return;
if(s[0].length!=0)
{
if(hcMain.location.pathname.indexOf(s[0])!=-1)
{
hcMain.navigateBox(s[1]);
}
else
{
hcMain.location.replace(strSrc)
}
}
else
{
hcMain.navigateBox(s[1]);
}
}
}
function OnResizerStartMoving()
{
ListResizer.setCapture()
bCapture = true
}
function OnResizerMoving()
{
if (bCapture)
MoveResizer()
}
function MoveResizer()
{
var y = window.event.clientY + document.body.scrollTop
var top = parseInt(PersonList.style.top) + 30
if (y <= top)
y = top
ListResizer.style.top = y
}
function OnResizerMouseUp()
{
if (bCapture)
{
MoveResizer()
var y = parseInt(ListResizer.style.top)
PersonList.style.height = y - 5 - parseInt(PersonList.style.top)
var nItem = PersonList.selectedIndex
if (nItem >=0)
OnSelected( PersonList.options[ nItem ].value );
ListResizer.releaseCapture()
bCapture = false
onResize()
}
}